import Vue from "vue";
import VueRouter from "vue-router";
import routerView from "./../routerView.vue";
import { isPhone } from "./../config";

Vue.use(VueRouter);

const rePath = isPhone() ? "/m-home" : "/pc-home";

const routes = [
  {
    path: "/",
    name: "home",
    redirect: rePath,
    component: routerView,
    children: [
      {
        path: "/m-home",
        name: "mobile-home",
        meta: {
          title: "移动端首页",
        },
        component: () => import("./../views/m-home.vue"),
      },
      {
        path: "/pc-home",
        name: "pc-home",
        meta: {
          title: "移动端首页",
        },
        component: () => import("./../views/pc-home.vue"),
      },
    ],
  },
];

const router = new VueRouter({
  base: process.env.BASE_URL,
  routes,
});

export default router;
